{template "content","header"}
<link href="{CSS_PATH}showLoading.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{JS_PATH}jquery.form.js"></script>
<script type="text/javascript" src="{JS_PATH}jquery.showLoading.min.js"></script>

<!-- 所在  -->
<div class="path-box wrap2 cl">
    <I class="icon home"></I>
    <span class="path"><a href="{siteurl($siteid)}">新疆维吾尔自治区林业规划院</a></span><span>&nbsp;&gt;&nbsp;</span>留言板
</div>

<div class="text-list wrap2 cl">
    <div class="inner">
        <div class="article-box">
            <div class="message">{$name}</div>
        </div>
        <form method="post" action="?m=formguide&c=index&a=show&formid={$formid}" name="myform" id="myform">
            <table class="message-box">
                {loop $forminfos_data $field $info}
                {if $info['formtype']=='omnipotent'}
                {loop $forminfos_data $_fm $_fm_value}
                {if $_fm_value['iscomnipotent']}
                {php $info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$info['form']);}
                {/if}
                {/loop}
                {/if}
                {if $info['name']!='回复内容'}
                <tr>
                    <td class="messagetitle">{if $info['star']} <span>*</span>{/if} {$info['name']}：</td>
                    <td>{$info['form']}  {$info['tips']}</td>
                </tr>
                {/if}
                {/loop}
                <tr>
                    <td class="messagetitle" style="height: 30px;">{L('checkcode', null, 'member')}：</td>
                    <td>
                        <div style='width: 70px;float: left;'>
                            <input type="text" id="code" name="code" size="10" class="input-text" style="width: 70px;">
                        </div>
                        &nbsp;
                        <div style='width: 120px;float: left;margin-left: 16px;margin-top: 3px;'>{form::checkcode('code_img', '5', '14', 120, 33)}</div>
                    </td>
                </tr>
                <tr>
                    <td class="messagetitle" style="height: 30px;"></td>
                    <td>
                        <button type="submit" name="dosubmit" id="dosubmit" style="background: #004B97; color:#ffffff;">留言</button>&nbsp;&nbsp;
                        <span id="loading" style="margin-left: 30px;"></span>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $('#myform').ajaxForm({  
            beforeSubmit: validate,
            success: showResponse,
            timeout: 10000
        });
    });
    
    function validate(formData, jqForm, options) {
        var session_code = $.trim($('#code').val());
        
        if(session_code == '') {
            alert('请输入验证码');
            $('#code').focus();
            return false;
        }
        
        $("#loading").showLoading();
    }
    
    function showResponse(responseText, statusText) {
        var result = $.parseJSON(responseText);
        $("#loading").hideLoading();
        
        if(result && result.errMsg) {
            alert(result.errMsg);
        }else if(result && result.successMsg) {
            alert(result.successMsg);
            window.location.href = result.url;
        }else {
            alert("网络异常，请联系管理员！");
        }
    }
</script>

{template "content","footer"}